package core;

import org.easyway.collisions.GroupCollision;
import org.easyway.interfaces.extended.ILoopable;
import org.easyway.objects.sprites2D.Mask;
import org.easyway.objects.sprites2D.SpriteColl;
import org.easyway.objects.texture.Texture;

@SuppressWarnings("serial")
public class Shot extends SpriteColl implements ILoopable {
	
	protected static Texture image;
	protected float speed = -3.0f;
	
	public static void init() {
		if (image != null)
			return;
		image = new Texture("images/shot.png", 255, 255, 255);
		new Mask(image);
	}

	public Shot(float x, float y) {
		super(x, y, image);
		GroupCollision group = GroupCollision.getGroup("myGroup");
		group.source.add(this);
	}
	
	public void onCollision() {
		destroy();
	}
	
	public void loop() {
		incY(speed);
		if (getY() + getHeight() < 0) {
			destroy();
		}
	}
	
	protected void onDestroy() {
		Player.signalShotOut();
	}
}
